<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCustomerInfosTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_infos', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->unsigned()->comment('用户ID');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->string('name')->comment('姓名');
            $table->string('phone')->comment('手机');
            $table->bigInteger('vehicle_id')->unsigned()->comment('车型ID');
            $table->foreign('vehicle_id')->references('id')->on('vehicles')->onDelete('restrict');
            $table->bigInteger('activity_id')->unsigned()->index()->nullable()->comment('活动ID');
            $table->string('province')->comment('省份');
            $table->string('city')->comment('城市');
            $table->bigInteger('dealer_id')->unsigned()->comment('经销商ID');
            $table->foreign('dealer_id')->references('id')->on('dealers')->onDelete('restrict');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_infos');
    }
}
